
package org.zerta.troops.client;

import java.awt.Dimension;

import javax.swing.BoxLayout;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;

class GamePanel extends JPanel
{
	private static final long serialVersionUID = 1L;

	private GameController controller;
	
	private MapPanel mappanel;
    private InfoPanel infopanel;
    private JScrollPane mapscroller;
    private JScrollPane infoscroller;     
    private JSplitPane splitpane;

    GamePanel(GameController c)
    {
    	// The GUIs communication line to the "real world"
    	controller = c;
    	
	    // The main two GUI components
	    mappanel = new MapPanel(controller);
	    infopanel = new InfoPanel(controller);
	    
	    // Wrap panels in scrollers
	    mapscroller = new JScrollPane(mappanel);
	    infoscroller = new JScrollPane(infopanel);
	    mapscroller.setMinimumSize(new Dimension(0,0));
	    infoscroller.setMinimumSize(new Dimension(0,0));

	    // Wrap scrollers in a split pane
	    splitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
	    splitpane.setOneTouchExpandable(true);
	    splitpane.setContinuousLayout(true);
	    splitpane.setLeftComponent(mapscroller);
	    splitpane.setRightComponent(infoscroller);
	    splitpane.setDividerLocation(0.8);

	    /*
	    setLayout(new GridBagLayout());
	    GridBagConstraints constraints = new GridBagConstraints();
	    constraints.fill = GridBagConstraints.BOTH;
	    add(splitpane, constraints);
	    */
	    
	    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
	    add(splitpane);
    }
}
